/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * QuanLyLichTrinh.java
 *
 * Created on Oct 12, 2012, 3:56:40 PM
 */
package Panel;

import DAO.LichTrinhDAO;
import DAO.TauDAO;
import DAO.TuyenDuongDAO;
import OBJECT.LichTrinh;
import java.awt.event.ItemEvent;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.util.Calendar;
import java.util.Date;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author TAN
 */
public class QuanLyLichTrinh extends javax.swing.JPanel {
    Calendar cal;
    Calendar cal1;
    LichTrinhDAO ltdao;
    TuyenDuongDAO tddao;
    TauDAO          tdao;
    DefaultTableModel tablemodelLichTrinh;
    DefaultTableModel tablemodelTau;
    DefaultTableModel tablemodelTuyenDuong;
    /** Creates new form QuanLyLichTrinh */
    public QuanLyLichTrinh(String User ,String Pass,String port,String DataBase,String Host) {
        initComponents(); 
        txtMalt.setEditable(false);
                 txtMaTuyen.setEditable(true);
                 txtMaTau.setEditable(true);
                 txtcontent.setEditable(false);
                 txtTinhTrang.setEditable(false);
        initcomboxNgayDen();
        initcomboxNgayKH();
        tbLichTrinh.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
          tablemodelLichTrinh = new DefaultTableModel();
        tablemodelLichTrinh.addColumn("Mã Lt");
        tablemodelLichTrinh.addColumn("Mã Tuyến Đường");
        tablemodelLichTrinh.addColumn("Mã Tàu");
        tablemodelLichTrinh.addColumn("Thời Gian Khởi Hành");
        tablemodelLichTrinh.addColumn("Thời Gian Đến");
        tablemodelLichTrinh.addColumn("Số Contenter Còn Trống");
        tablemodelLichTrinh.addColumn("Tình Trạng");
        tbLichTrinh.setModel(tablemodelLichTrinh);
         
        tablemodelTau =new DefaultTableModel();
        tablemodelTau.addColumn("Mã Tàu");
        tablemodelTau.addColumn("Tên Tàu");
        tablemodelTau.addColumn("Loại Tàu");
        tablemodelTau.addColumn("Tình Trạng Tàu");
        tbtau.setModel(tablemodelTau);
        
        tablemodelTuyenDuong=new DefaultTableModel();
        tablemodelTuyenDuong.addColumn("Mã Tuyến");
        tablemodelTuyenDuong.addColumn("Tên Tuyến");
        tablemodelTuyenDuong.addColumn("Ga Xuất Phát");
        tablemodelTuyenDuong.addColumn("Ga Cuối");
        tablemodelTuyenDuong.addColumn("Km");
        tablemodelTuyenDuong.addColumn("Tình Trạng");
        tbtuyenduong.setModel(tablemodelTuyenDuong);
        ltdao =new LichTrinhDAO(User , Pass, port, DataBase, Host);
        tddao= new TuyenDuongDAO(User , Pass, port, DataBase, Host);
        tdao=new TauDAO(User , Pass, port, DataBase, Host);
         showList();
         Show2List();
         show3list();
        
    }
        private void initcomboxNgayKH(){
        DefaultComboBoxModel ngay= new DefaultComboBoxModel();
        DefaultComboBoxModel thang= new DefaultComboBoxModel();
        DefaultComboBoxModel nam = new DefaultComboBoxModel();
        DefaultComboBoxModel gio = new DefaultComboBoxModel();
        DefaultComboBoxModel phut = new DefaultComboBoxModel();
        cal = Calendar.getInstance();
        for(int i=1;i<=31;i++)
            ngay.addElement(i);
        for(int i=1;i<=12;i++)
            thang.addElement(i);
        for(int i=1900;i<=cal.get(Calendar.YEAR)+1;i++)
            nam.addElement(i);
        for(int i=0;i<24;i++)
            gio.addElement(i);
        for(int i=0;i<60;i++)
            phut.addElement(i);
        cbngaykh.setModel(ngay);
        cbnamkh.setModel(nam);
        cbthangkh.setModel(thang);
        cbgiokh.setModel(gio);
        cbphutkh.setModel(phut);
        
    }
           private void initcomboxNgayDen(){
        DefaultComboBoxModel ngay= new DefaultComboBoxModel();
        DefaultComboBoxModel thang= new DefaultComboBoxModel();
        DefaultComboBoxModel nam = new DefaultComboBoxModel();
        DefaultComboBoxModel gio = new DefaultComboBoxModel();
        DefaultComboBoxModel phut = new DefaultComboBoxModel();
        cal1 = Calendar.getInstance();
        for(int i=1;i<=31;i++)
            ngay.addElement(i);
        for(int i=1;i<=12;i++)
            thang.addElement(i);
        for(int i=1900;i<=cal1.get(Calendar.YEAR)+1;i++)
            nam.addElement(i);
        for(int i=0;i<24;i++)
            gio.addElement(i);
        for(int i=0;i<60;i++)
            phut.addElement(i);
        cbngayden.setModel(ngay);
        cbnamden.setModel(nam);
        cbthangden.setModel(thang);
        cbgioden.setModel(gio);
        cbphutden.setModel(phut);
        
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbtuyenduong = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tbtau = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtMalt = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtMaTuyen = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        txtMaTau = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        cbngaykh = new javax.swing.JComboBox();
        cbnamkh = new javax.swing.JComboBox();
        cbthangkh = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        cbgiokh = new javax.swing.JComboBox();
        cbphutkh = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        cbngayden = new javax.swing.JComboBox();
        cbthangden = new javax.swing.JComboBox();
        cbnamden = new javax.swing.JComboBox();
        cbgioden = new javax.swing.JComboBox();
        cbphutden = new javax.swing.JComboBox();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        txtcontent = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        txtTinhTrang = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        cbThaoTac = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tbLichTrinh = new javax.swing.JTable();
        lbSoLuong = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(204, 204, 255));

        jPanel1.setBackground(new java.awt.Color(0, 153, 153));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Danh Sách Các Tuyến Đường", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), java.awt.Color.orange)); // NOI18N

        tbtuyenduong.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tbtuyenduong);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 392, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(60, 60, 60))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(24, Short.MAX_VALUE))
        );

        jPanel2.setBackground(new java.awt.Color(0, 153, 153));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Danh Sách Các Tàu", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), java.awt.Color.orange)); // NOI18N

        tbtau.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(tbtau);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 394, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel3.setBackground(new java.awt.Color(204, 204, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Thông Tin Lịch Trình", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), java.awt.Color.darkGray)); // NOI18N

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(0, 102, 51));
        jLabel1.setText("Mã _LT");

        txtMalt.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtMaltFocusLost(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(0, 102, 51));
        jLabel2.setText("Mã Tuyến");

        txtMaTuyen.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtMaTuyenFocusLost(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(0, 102, 51));
        jLabel3.setText("Mã Tàu");

        txtMaTau.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtMaTauFocusLost(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(0, 102, 51));
        jLabel4.setText("Khởi Hành");

        cbngaykh.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        cbnamkh.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        cbthangkh.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(0, 102, 51));
        jLabel5.setText("Ngày");

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel6.setForeground(new java.awt.Color(0, 102, 51));
        jLabel6.setText("Tháng");

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(0, 102, 51));
        jLabel7.setText("Năm");

        cbgiokh.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        cbphutkh.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(0, 102, 51));
        jLabel8.setText("Giờ");

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(0, 102, 51));
        jLabel9.setText("Phút");

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel10.setForeground(new java.awt.Color(0, 102, 51));
        jLabel10.setText("Đến Lúc");

        cbngayden.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        cbthangden.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        cbnamden.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        cbgioden.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        cbphutden.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel11.setForeground(new java.awt.Color(0, 102, 51));
        jLabel11.setText("Ngày");

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel12.setForeground(new java.awt.Color(0, 102, 51));
        jLabel12.setText("Tháng");

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel13.setForeground(new java.awt.Color(0, 102, 51));
        jLabel13.setText("Năm");

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel14.setForeground(new java.awt.Color(0, 102, 51));
        jLabel14.setText("Giờ");

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel15.setForeground(new java.awt.Color(0, 102, 51));
        jLabel15.setText("Phút");

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel16.setForeground(new java.awt.Color(0, 102, 51));
        jLabel16.setText("Contener");

        txtcontent.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtcontentFocusLost(evt);
            }
        });

        jLabel17.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel17.setForeground(new java.awt.Color(0, 102, 51));
        jLabel17.setText("Tình Trạng");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel16)
                            .addComponent(jLabel10))
                        .addGap(21, 21, 21))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addGap(18, 18, 18)))
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtcontent)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbngayden, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel14)
                            .addComponent(cbgioden, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel13))
                            .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(cbthangden, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cbnamden, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(cbphutden, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(txtTinhTrang)
                                .addComponent(txtMaTuyen)
                                .addComponent(txtMaTau, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
                                .addComponent(txtMalt))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cbngaykh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel8)
                                    .addComponent(cbgiokh, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel9)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(cbthangkh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(cbnamkh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(cbphutkh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(jLabel6)
                                        .addGap(18, 18, 18)
                                        .addComponent(jLabel7)))))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap(0, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtMalt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(txtMaTuyen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtMaTau, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(txtTinhTrang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7)))
                    .addComponent(jLabel17))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbngaykh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbthangkh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbnamkh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbphutkh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbgiokh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(txtcontent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12)
                    .addComponent(jLabel13))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbngayden, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbthangden, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbnamden, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbgioden, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbphutden, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBackground(new java.awt.Color(0, 153, 153));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Thao Tác", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Adobe Caslon Pro", 1, 14), java.awt.Color.orange)); // NOI18N

        cbThaoTac.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Insert", "Update", "Delete" }));
        cbThaoTac.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbThaoTacItemStateChanged(evt);
            }
        });

        jButton1.setBackground(new java.awt.Color(204, 204, 204));
        jButton1.setText("Apply");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(55, 55, 55)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cbThaoTac, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(58, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(cbThaoTac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(20, 20, 20))
        );

        jPanel5.setBackground(new java.awt.Color(0, 153, 153));
        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Danh Sách Lịch Trình", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), java.awt.Color.orange)); // NOI18N

        tbLichTrinh.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tbLichTrinh.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tbLichTrinhMousePressed(evt);
            }
        });
        jScrollPane3.setViewportView(tbLichTrinh);

        lbSoLuong.setText("jLabel17");

        jLabel18.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel18.setForeground(new java.awt.Color(204, 204, 0));
        jLabel18.setText("Lịch Trình");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(lbSoLuong)
                        .addGap(31, 31, 31)
                        .addComponent(jLabel18)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbSoLuong)
                    .addComponent(jLabel18))
                .addGap(30, 30, 30)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 426, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(101, 101, 101)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(10, 10, 10)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(37, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void cbThaoTacItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbThaoTacItemStateChanged
        // TODO add your handling code here
        if(evt.getStateChange() == ItemEvent.SELECTED){
            String option = this.cbThaoTac.getSelectedItem().toString();
            Clear();
             if(option.equals("Insert")){
                 txtMalt.setEditable(false);
                 txtMaTuyen.setEditable(true);
                 txtMaTau.setEditable(true);
                 txtcontent.setEditable(false);
                 txtTinhTrang.setEditable(false);
             }
             else if(option.equals("Update"))
             {
                 txtMalt.setEditable(true);
                 txtMaTuyen.setEditable(true);
                 txtMaTau.setEditable(true);
                 txtcontent.setEditable(true);
                 txtTinhTrang.setEditable(true);
             }
             else if(option.equals("Delete"))
             {
                 txtMalt.setEditable(true);
                 txtMaTuyen.setEditable(false);
                 txtMaTau.setEditable(false);
                 txtcontent.setEditable(false);
                 txtTinhTrang.setEditable(false);
             }
        }
    }//GEN-LAST:event_cbThaoTacItemStateChanged

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
         String option = cbThaoTac.getSelectedItem().toString();
         if(option.equals("Insert"))
         {
             LichTrinh lt= new LichTrinh();
             lt.setMaTau(Integer.parseInt(txtMaTau.getText()));
             lt.setMaTuyenDuong(Integer.parseInt(txtMaTuyen.getText()));
             
          int ngaykh = Integer.parseInt(cbngaykh.getSelectedItem().toString());
        int thangkh = Integer.parseInt(cbthangkh.getSelectedItem().toString());
        int namkh = Integer.parseInt(cbnamkh.getSelectedItem().toString());
        int giokh = Integer.parseInt(cbgiokh.getSelectedItem().toString());
        int phutkh=Integer.parseInt(cbphutkh.getSelectedItem().toString());
        Date datekh = new Date(namkh-1900, thangkh-1, ngaykh,giokh,phutkh);
        lt.setTGKhoiHanh(datekh);
        
          int ngayden = Integer.parseInt(cbngayden.getSelectedItem().toString());
        int thangden = Integer.parseInt(cbthangden.getSelectedItem().toString());
        int namden = Integer.parseInt(cbnamden.getSelectedItem().toString());
        int gioden = Integer.parseInt(cbgioden.getSelectedItem().toString());
        int phutden=Integer.parseInt(cbphutden.getSelectedItem().toString());
        Date date = new Date(namden-1900, thangden-1, ngayden,gioden,phutden);
        lt.setTGDen(date);
        String kt=ltdao.ThemLichTrinh(lt);
         JOptionPane.showMessageDialog(this, kt,"OK",JOptionPane.INFORMATION_MESSAGE);
         }
         else if(option.equals("Update"))
         {
             if(txtMalt.getText().equals("")){
            JOptionPane.showMessageDialog(this, "Không Thể Bỏ Trống Mã Lịch Trình","Error",JOptionPane.ERROR_MESSAGE);
            return;
        }
              LichTrinh lt= new LichTrinh();
             lt.setMaTau(Integer.parseInt(txtMaTau.getText()));
             lt.setMaTuyenDuong(Integer.parseInt(txtMaTuyen.getText()));
             lt.setMaLichTrinh(Integer.parseInt(txtMalt.getText()));
             lt.setContent(Integer.parseInt(txtcontent.getText()));
             lt.setTinhTrang(txtTinhTrang.getText());
          int ngaykh = Integer.parseInt(cbngaykh.getSelectedItem().toString());
        int thangkh = Integer.parseInt(cbthangkh.getSelectedItem().toString());
        int namkh = Integer.parseInt(cbnamkh.getSelectedItem().toString());
        int giokh = Integer.parseInt(cbgiokh.getSelectedItem().toString());
        int phutkh=Integer.parseInt(cbphutkh.getSelectedItem().toString());
        Date datekh = new Date(namkh-1900, thangkh-1, ngaykh,giokh,phutkh);
        lt.setTGKhoiHanh(datekh);
        
          int ngayden = Integer.parseInt(cbngayden.getSelectedItem().toString());
        int thangden = Integer.parseInt(cbthangden.getSelectedItem().toString());
        int namden = Integer.parseInt(cbnamden.getSelectedItem().toString());
        int gioden = Integer.parseInt(cbgioden.getSelectedItem().toString());
        int phutden=Integer.parseInt(cbphutden.getSelectedItem().toString());
        Date date = new Date(namden-1900, thangden-1, ngayden,gioden,phutden);
        lt.setTGDen(date);
         }
         else if(option.equals("Delete"))
         {
            if(txtMalt.getText().equals(""))
             {
                 JOptionPane.showMessageDialog(null, "Nhập Mã Lịch Trình Cần Xóa", "Error", JOptionPane.ERROR_MESSAGE);
                return;
             } 
            int inform = JOptionPane.showConfirmDialog(null, "Bạn Có Muốn Xóa Hay Không ???");
             if(inform == JOptionPane.OK_OPTION){
           String kt= ltdao.XoaLichTrinh(Integer.parseInt(txtMalt.getText()));
            
            
                JOptionPane.showMessageDialog(this, kt,"OK",JOptionPane.INFORMATION_MESSAGE);
            clearList();
            showList();
            
             
             }
         }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void tbLichTrinhMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbLichTrinhMousePressed
        // TODO add your handling code here:
        String option = this.cbThaoTac.getSelectedItem().toString();
     if(option.equals("Insert"))
     {
         JOptionPane.showMessageDialog(this, "tabel không thể thao tác khi ở chế độ insert","Error",JOptionPane.ERROR_MESSAGE);
         return;
     }
     else
     {
         LichTrinh lt ;
    int row = this.tbLichTrinh.getSelectedRow();
   
    lt = ltdao.Search1LichTrinh(Integer.parseInt(tbLichTrinh.getValueAt(row, 0).toString()));
    txtMaTau.setText(""+lt.getMaTau());
    txtMaTuyen.setText(""+lt.getMaTuyenDuong());
    txtMalt.setText(""+lt.getMaLichTrinh());
    txtTinhTrang.setText(lt.getTinhTrang());
    txtcontent.setText(""+lt.getContent());
     cbnamkh.setSelectedIndex(lt.getTGKhoiHanh().getYear());
    cbngaykh.setSelectedIndex(lt.getTGKhoiHanh().getDate()-1);
    cbthangkh.setSelectedIndex(lt.getTGKhoiHanh().getMonth());
    cbgiokh.setSelectedIndex(lt.getTGKhoiHanh().getHours());
    cbphutkh.setSelectedIndex(lt.getTGKhoiHanh().getMinutes());
    
    cbnamden.setSelectedIndex(lt.getTGDen().getYear());
    cbngayden.setSelectedIndex(lt.getTGDen().getDate()-1);
    cbthangden.setSelectedIndex(lt.getTGDen().getMonth());
    cbgioden.setSelectedIndex(lt.getTGDen().getHours());
    cbphutden.setSelectedIndex(lt.getTGDen().getMinutes());
   
     }
    }//GEN-LAST:event_tbLichTrinhMousePressed

    private void txtcontentFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtcontentFocusLost
        // TODO add your handling code here:
        try{
            if(!this.txtcontent.getText().equals("")){
             Float temp = Float.parseFloat(this.txtcontent.getText());
            }
            else{
                this.txtcontent.setText("1");
            }
        }catch(NumberFormatException e){
            JOptionPane.showMessageDialog(null, "contener Phải Là Số");
            this.txtcontent.setText("");
            this.txtcontent.requestFocus();
        }
    }//GEN-LAST:event_txtcontentFocusLost

    private void txtMaltFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtMaltFocusLost
        // TODO add your handling code here:
        try{
            if(!this.txtMalt.getText().equals("")){
             Float temp = Float.parseFloat(this.txtMalt.getText());
            }
            else{
                this.txtMalt.setText("");
            }
        }catch(NumberFormatException e){
            JOptionPane.showMessageDialog(null, "MaLt Phải Là Số");
            this.txtMalt.setText("");
            this.txtMalt.requestFocus();
        }
    }//GEN-LAST:event_txtMaltFocusLost

    private void txtMaTuyenFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtMaTuyenFocusLost
        // TODO add your handling code here:
         try{
            if(!this.txtMaTuyen.getText().equals("")){
             Float temp = Float.parseFloat(this.txtMaTuyen.getText());
            }
            else{
                this.txtMaTuyen.setText("1");
            }
        }catch(NumberFormatException e){
            JOptionPane.showMessageDialog(null, "Mã Tuyến Phải Là Số");
            this.txtMaTuyen.setText("");
            this.txtMaTuyen.requestFocus();
        }
    }//GEN-LAST:event_txtMaTuyenFocusLost

    private void txtMaTauFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtMaTauFocusLost
        // TODO add your handling code here:
         try{
            if(!this.txtMaTau.getText().equals("")){
             Float temp = Float.parseFloat(this.txtMaTau.getText());
            }
            else{
                this.txtMaTau.setText("1");
            }
        }catch(NumberFormatException e){
            JOptionPane.showMessageDialog(null, "Mã tàu Phải Là Số");
            this.txtMaTau.setText("");
            this.txtMaTau.requestFocus();
        }
    }//GEN-LAST:event_txtMaTauFocusLost
private void Clear(){
        txtMaTau.setText("");
        txtMaTuyen.setText("");
        txtMalt.setText("");
        txtTinhTrang.setText("");
        txtcontent.setText("");
        
    }
private void Show2List()
{
    CallableStatement cls=tddao.DanhSachTuyenDuong();
                   try
                   {                  
                      cls.execute();
                      ResultSet result=cls.getResultSet();  
                   while(result.next())
                    {
                            Vector vt = new Vector();
                            vt.add(result.getInt("Ma_TuyenDuong"));
                            vt.add(result.getString("Ten_TuyenDuong"));
                            vt.add(result.getString("GaXuatPhat"));                            
                            vt.add(result.getString("GaCuoiCung"));
                            vt.add(result.getFloat("TongKM"));
                            vt.add(result.getString("TinhTrangTD"));
                            tablemodelTuyenDuong.addRow(vt);
                           
                    }
                   result.close();                          
                    cls.close();
                    tddao.CloseConnect();
                   }catch(Exception e)
                   {
                      ;
                   }
}
private void show3list()
{
   CallableStatement cls=tdao.DanhSachTau();
                   try
                   {
                        cls.execute();
                        ResultSet result=cls.getResultSet();  
                        while(result.next())
                    {
                           if(result.getString("TinhTrangTau").equals("2")==false)
                           {
                            Vector vt = new Vector();
                            vt.add(result.getInt("Ma_Tau"));
                            vt.add(result.getString("TenTau"));
                            vt.add(result.getInt("LoaiTau"));
                             vt.add(result.getString("TinhTrangTau"));
                            tablemodelTau.addRow(vt);
                           }
                    }
                   result.close();
                          
                    cls.close();
                    tdao.CloseConnect();
                   }catch(Exception e)
                   {
                      ;
                   } 
}
private void showList()
{
                    String Soluong="";
                   CallableStatement cls=ltdao.DanhSachLichTrinh();
                   try
                   {
                   cls.registerOutParameter(1, java.sql.Types.INTEGER);   //lay ket qua DEM output  trong store                
                   cls.execute();
                   ResultSet result=cls.getResultSet(); 
                   while(result.next())
                    {
                           if(result.getString("TinhTrang").equals("2")==false)
                           {
                            Vector vt = new Vector();
                            vt.add(result.getInt("Ma_LichTrinhVC"));
                            vt.add(result.getInt("Ma_TuyenDuong"));
                            vt.add(result.getInt("Ma_Tau"));
                            Date d=result.getTimestamp("ThoiGianKhoiHanh");
                            vt.add(d.getDate()+"-"+(int)(d.getMonth()+1)+"-"+(int)(d.getYear()+1900));
                            Date d1=result.getTimestamp("ThoiGianDen");
                            vt.add(d1.getDate()+"-"+(int)(d1.getMonth()+1)+"-"+(int)(d1.getYear()+1900));
                             vt.add(result.getInt("SoContainerConTrong"));
                             vt.add(result.getString("TinhTrang"));
                            tablemodelLichTrinh.addRow(vt);
                           }
                    }
                   result.close();
                     Soluong=""+cls.getInt(1);
                    cls.close();
                    ltdao.CloseConnect();
                   }catch(Exception e)
                   {
                      ;
                   }
                
                   lbSoLuong.setText(Soluong);
                   
             
}
private void clearList()
{
   for(int i = tablemodelLichTrinh.getRowCount() -1;i >= 0;i--)
            tablemodelLichTrinh.removeRow(i);
   
}

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cbThaoTac;
    private javax.swing.JComboBox cbgioden;
    private javax.swing.JComboBox cbgiokh;
    private javax.swing.JComboBox cbnamden;
    private javax.swing.JComboBox cbnamkh;
    private javax.swing.JComboBox cbngayden;
    private javax.swing.JComboBox cbngaykh;
    private javax.swing.JComboBox cbphutden;
    private javax.swing.JComboBox cbphutkh;
    private javax.swing.JComboBox cbthangden;
    private javax.swing.JComboBox cbthangkh;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JLabel lbSoLuong;
    private javax.swing.JTable tbLichTrinh;
    private javax.swing.JTable tbtau;
    private javax.swing.JTable tbtuyenduong;
    private javax.swing.JTextField txtMaTau;
    private javax.swing.JTextField txtMaTuyen;
    private javax.swing.JTextField txtMalt;
    private javax.swing.JTextField txtTinhTrang;
    private javax.swing.JTextField txtcontent;
    // End of variables declaration//GEN-END:variables
}
